package com.chenchao.web;

import java.io.*;
import java.net.Socket;

/**
 * @encoding : UTF-8
 * @Time : 2020/11/26 16:17
 * @Author : Chen Chao
 * @File : javaSE.com.chenchao.web.Test01A.java
 * @Software : IntelliJ IDEA
 * @since : 1.8
 */
public class Test01A {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("localhost",10000);
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
        BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("myjava01/src/fo/test/get")));
        String str;
        while ((str=reader.readLine())!=null){
            writer.write(str);
            writer.newLine();
        }
        writer.flush();
        /*writer一定要及时flush*/
        socket.shutdownOutput();
        BufferedReader reader1 = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        while ((str=reader1.readLine())!=null){
            System.out.println(str);
        }
    }
}
